project(sqlite3)

# 添加源文件
set(SQLITE3_SOURCES
    sqlite3.c
)

# 创建静态库目标
add_library(sqlite3 STATIC ${SQLITE3_SOURCES})

# 设置编译选项
target_compile_definitions(sqlite3 PRIVATE
    SQLITE_ENABLE_RTREE
    SQLITE_ENABLE_FTS4
    SQLITE_ENABLE_FTS5
    SQLITE_ENABLE_JSON1
    SQLITE_ENABLE_COLUMN_METADATA
    SQLITE_THREADSAFE=1
)

# 设置包含目录
target_include_directories(sqlite3 PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

# 添加shell可执行目标
add_executable(sqlite3_shell shell.c)
target_link_libraries(sqlite3_shell PRIVATE sqlite3 pthread m dl)

# 安装规则
install(TARGETS sqlite3 sqlite3_shell
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
    PUBLIC_HEADER DESTINATION include
)

install(FILES sqlite3.h sqlite3ext.h
    DESTINATION include
)